let spinning =false
function chou(){
    let wheel = document.getElementById('wheel');
    wheel.style.transformOrigin = '50% 50%';
    if (spinning) return;
    spinning = true;
    let randomOffset = Math.floor(Math.random() * 20) + 75;
    let randomExtraRotation = 1050;
    let totalRotation = randomExtraRotation + randomOffset;
    wheel.style.transition = 'transform 3s cubic-bezier(0.1, 0.1, 0.25, 1)';
    wheel.style.transform = `rotate(${totalRotation}deg)`;
    setTimeout(() => {
        wheel.style.transition = 'transform .5s ease-in-out)';
        wheel.style.transform = `rotate(${totalRotation - 45}deg)`;
        setTimeout(() => {
            showGongxiImg()
            setTimeout(() => {
                closeGongxiImg()
                showlist()
                num200()
            }, 1500);
        }, 2000);
    }, 3000);
}
// 关闭灯光+恭喜
function closeGongxiImg() {
    var True = document.getElementById('modulSpinner_light');
    True.style.display = 'none';
}
// 显示灯光+恭喜
function showGongxiImg() {
    var True = document.getElementById('modulSpinner_light');
    True.style.display = 'block';
    let gongxiImg = document.querySelector('.gongxiImg');
    // 初始化图片位置
    gongxiImg.style.opacity = 0;
    gongxiImg.style.transform = 'translateY(100%)';
    gongxiImg.style.transition = 'none';
    // 强制浏览器重新计算样式，以确保上面的初始化生效
    gongxiImg.offsetHeight;
    // 开始动画：由下到上，逐渐显示
    gongxiImg.style.transition = 'transform 1s ease-out, opacity 1s ease-out';
    gongxiImg.style.opacity = 1;
    gongxiImg.style.transform = 'translateY(0)';
}
// 显示立即充值的弹窗
function showlist(){
    var True = document.getElementById('modulSpinner');
    True.style.display = 'block';
}
function toGet() {
    let str = $('#mobile').val().trim();
    if (str) {
        var myreg = /^1([3456789])\d{9}$/;
        if (!myreg.test(str)) {
            alert('手机号格式不正确');
        } else {
            const params = window.location.search;  // 获取当前页面的URL参数
            let newUrl = 'newIndex.html';
            let encodedPhone = btoa(str);
            if (params) {
                newUrl += params + '&phone=' + encodeURIComponent(encodedPhone);
            } else {
                newUrl += '?phone=' + encodeURIComponent(encodedPhone);
            }
            window.location.href = newUrl;
        }
    } else {
        alert('请先输入手机号');
    }
}
function getPhoneList(){
    $.ajax({
        type: 'GET',
        url: httpUrl+'/api/v1/open/searchPhone',
        success: function(data) {
            if(data.code=='10000'){
                var phoneList =data.data;
                if(phoneList.length){
                    for (let i = 0; i < phoneList.length; i++) {
                        var rewards = [
                            '成功领取 200元话费',
                            '成功领取 0.5元现金红包',
                            '成功领取 保温水杯',
                            '成功领取 18.8元现金红包',
                            '成功领取 电饭煲'
                        ];
                        var randomReward = rewards[Math.floor(Math.random() * rewards.length)];
                        var item = phoneList[i];
                        var scrollText = document.getElementById("scrollText");
                        var span = document.createElement("span");
                        span.textContent ="恭喜 "+ item +' '+randomReward;
                        scrollText.appendChild(span);
                    }
                }
            }
        },
        error: function(xhr, status, error) {
        }
    });

}
function statistics(){
    $.ajax({
        type: 'GET',
        url: httpUrl+'/api/v1/open/statisticsRequests',
        success: function(data) {

        },
        error: function(xhr, status, error) {
        }
    });

}
function num200(){
    const numToolBox = document.getElementById('numToolBox');
    // 起始值和目标值
    const startValue = 1;
    const endValue = 200;
    const duration = 1000;
    // 计算每次递增的间隔时间
    const steps = endValue - startValue;
    const intervalTime = duration / steps; // 每次递增的时间间隔
    // 初始化当前值
    let currentValue = startValue;
    const incrementValue = () => {
        numToolBox.textContent = currentValue;
        if (currentValue < endValue) {
            currentValue++;
        } else {
            clearInterval(interval); // 达到目标后停止递增
        }
    };
    const interval = setInterval(incrementValue, intervalTime);
}
// getPhoneList()
statistics()


